package com.hujiang.basic.search.fullindex;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.hujiang.basic.framework.rest.validation.annotation.NotBlank;
import com.hujiang.basic.framework.rest.validation.annotation.NotNull;
import com.hujiang.basic.search.handler.impl.model.FullIndexRquest;
import com.hujiang.basic.search.model.HJResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@Api("全量索引 API")
@RequestMapping(value = "/v1/fullindex")
public class FullIndexController {

	@Autowired
	private FullIndexService service;

	@ApiOperation(value = "触发全量索引", httpMethod = "POST", response = HJResponse.class, notes = "全量索引post接口")
	@RequestMapping(value = "/trigger", method = RequestMethod.POST)
	@NotNull("req")
	@NotBlank({"req.url", "req.indexName"})
	public HJResponse triggerFullIndex(@RequestBody FullIndexRquest req)  {
		return HJResponse.ok(service.triggerFullIndex(req));
	}
}
